/**
 * 插入排序
 * @param {*} arr
 */
function insert(arr) {
  let temp = null
  for (let i = 1, len = arr.length; i < len; i++) {
    for (let j = i; j > 0; j--) {
      if (arr[j] < arr[j - 1]) {
        temp = arr[j]
        arr[j] = arr[j - 1]
        arr[j - 1] = temp
        temp = null
      } else {
        break
      }
    }
  }
  return arr
}
console.log(insert([1, 2, 5, 7, 8, 0, 9]))
